package business.impl;

import java.util.List;

import model.TPractice;
import model.Tnews;
import model.VStuinfo;
import model.Vnews;
import business.basic.iHibBaseDAO;
import business.basic.iHibBaseDAOImpl;
import business.dao.NewsDao;

public class NewsDaoImpl implements NewsDao {
	
	iHibBaseDAO bdao = null;
	public void setBdao (iHibBaseDAO bdao){
		this.bdao=bdao;
		
	}

	@Override
	public Tnews getnewsById(int id) {
		Tnews title = (Tnews) bdao.findById(Tnews.class,id);
		return title;
	}

	@Override
	public int addnews(Tnews model) {
		Object obj = bdao.insert(model);
		if (obj == null) {
			return 0;
		}
		return 1;
	}

	@Override
	public boolean upnews(Tnews model) {
		return bdao.update(model);
	}

	@Override
	public boolean delnews(int id) {
		return bdao.delete(Tnews.class, id);
	}

	@Override
	public List<Vnews> getnewss() {
		String sql = " from Vnews ";
		List<Vnews> modl = bdao.select(sql);
		return modl;
	}

	@Override
	public Vnews getVnewsbyid(int newsid) {
		String sql = " from Vnews  where newsid= ?  ";
		Object[] para = {newsid};
		Vnews modl = (Vnews) bdao.selectby(sql, para);
		return modl;
	}

}
